/******************************************************************************
 * * mmi_modem_adaptor_main.h
 *
 * *(C) Copyright 2019 Asr International Ltd.
 * * All Rights Reserved
 * ******************************************************************************/
#ifndef MMI_MODEM_ADAPTOR_MAIN_H
#define MMI_MODEM_ADAPTOR_MAIN_H

#ifdef __cplusplus
extern "C" {
#endif
#include "lv_watch.h"

#include "../../ril/ril.h"
#include "../include/ui_inter_msg_interface.h"
#include "mmi_modemadp_interface.h"

/******************************************************************************
 *
 *         type define
 *
 *******************************************************************************/
#ifndef TRUE
#define TRUE    1
#endif

#ifndef FALSE
#define FALSE    0
#endif


typedef enum
{
    UI_LOG_LEVEL_TRACE_1,             // not important info, maybe for debug
    UI_LOG_LEVEL_TRACE_2,             // normal info, maybe for state change, some variable\ ....
    UI_LOG_LEVEL_TRACE_3,             // important info, maybe for interface ....
    UI_LOG_LEVEL_WARNING,             // warning
    UI_LOG_LEVEL_ERROR,               // error
    UI_LOG_LEVEL_ASSERT               // assert, reset will follow
} UI_LOG_LEVEL;
#define UI_LOG_OUTPUT_LEVEL    UI_LOG_LEVEL_TRACE_1      // level bigger than this could be output
#define UI_LOG_FILTER_BITMAP   (0b11111111111)
#define BITPOS(x)    (1 << x)

#define UI_Log_Out(sub_module, level, outstring, ...) printf(outstring, ##__VA_ARGS__)

/******************************************************************************
 *
 *         Message ID
 *
 *******************************************************************************/
typedef enum
{
    MMI_MODEMADP_NW_MSG_ID_START = UI_MSG_MODEM_ADP_BASE,
    MMI_MODEMADP_POWER_UP_REQ    = MMI_MODEMADP_NW_MSG_ID_START,
    MMI_MODEMADP_POWER_OFF_REQ,

    // network
    MMI_MODEMADP_PLMN_SEARCH_REQ,
    MMI_MODEMADP_PLMN_SEARCH_STOP_REQ,
    // MMI_MODEMADP_GET_OPERATOR_REQ,            //not send message, respond at once using global management variable
    // MMI_MODEMADP_VOICE_REG_STATE_REQ,         //not send message, respond at once using global management variable
    // MMI_MODEMADP_SCREEN_STATE_REQ,            //not send message,
    MMI_MODEMADP_GET_CALI_INFO_REQ,
    MMI_MODEMADP_GET_SN_INFO_REQ,
    MMI_MODEMADP_SET_BAND_REQ,
    MMI_MODEMADP_SET_VOLTE_STATE_REQ,
    MMI_MODEMADP_NW_MSG_ID_END = MMI_MODEMADP_SET_VOLTE_STATE_REQ,

    // call
    MMI_MODEMADP_CC_MSG_ID_START,
    // MMI_MODEMADP_CALL_GET_CURRENT_CALLS,      //cannot send message, CLCC info needs to be returned in API parameter
    MMI_MODEMADP_CALL_DIAL = MMI_MODEMADP_CC_MSG_ID_START,
    MMI_MODEMADP_CALL_REQUEST_IMEI,              //cannot send message, IMEI needs to be returned in API parameter
    MMI_MODEMADP_CALL_REQUEST_BASEBAND_VERSION,
    MMI_MODEMADP_CALL_HANGUP,
    MMI_MODEMADP_CALL_HANGUP_WAITING_OR_BG,
    MMI_MODEMADP_CALL_HANGUP_FG_RESUME_BG,
    MMI_MODEMADP_CALL_SWITCH_WAITING_OR_HOLDING_AND_ACTIVE,
    MMI_MODEMADP_CALL_CONF,
    MMI_MODEMADP_CALL_SEPERATE_CONN,
    MMI_MODEMADP_CALL_EXPLICIT_CALL_TRANSFER,
    MMI_MODEMADP_CALL_UDUB,
    MMI_MODEMADP_CALL_ANSWER,
    MMI_MODEMADP_CALL_DTMF,
    MMI_MODEMADP_CALL_DTMF_START,
    MMI_MODEMADP_CALL_DTMF_STOP,
    MMI_MODEMADP_CALL_SET_MUTE,
    // MMI_MODEMADP_CALL_GET_MUTE,               //cannot send message, mute needs to be returned in API parameter
    MMI_MODEMADP_CC_MSG_ID_END = MMI_MODEMADP_CALL_SET_MUTE,

    // sms
    MMI_MODEMADP_SMS_MSG_ID_START,
    MMI_MODEMADP_SEND_SMS_REQ  = MMI_MODEMADP_SMS_MSG_ID_START,
    MMI_MODEMADP_DEL_SMS_REQ,
    MMI_MODEMADP_READ_SMS_INFO_REQ,
    MMI_MODEMADP_READ_SMS_DETAIL_ON_SIM_REQ,
    MMI_MODEMADP_GET_SMSC_REQ,
    MMI_MODEMADP_SET_SMSC_REQ,
    MMI_MODEMADP_OPEN_VOLTE_REQ,
    // MMI_MODEMADP_SET_DELIVERY_REP_REQ,
    MMI_MODEMADP_SMS_MSG_ID_END       = MMI_MODEMADP_OPEN_VOLTE_REQ,

    // ss
    MMI_MODEMADP_SS_MSG_ID_START,
    MMI_MODEMADP_CALL_FORWARD_SET_REQ = MMI_MODEMADP_SS_MSG_ID_START,
    MMI_MODEMADP_CALL_FORWARD_QUERY_REQ,
    MMI_MODEMADP_CALL_WAIT_SET_REQ,
    MMI_MODEMADP_CALL_WAIT_QUERY_REQ,
    MMI_MODEMADP_SEND_USSD_REQ,
    MMI_MODEMADP_USSD_CANCEL_REQ,
    MMI_MODEMADP_SS_MSG_ID_END   = MMI_MODEMADP_USSD_CANCEL_REQ,

    // sim
    MMI_MODEMADP_SIM_MSG_ID_START,
    MMI_MODEMADP_ENABLE_PIN_LOCK = MMI_MODEMADP_SIM_MSG_ID_START,
    MMI_MODEMADP_QUERY_FACILITY_PIN_LOCK,
    MMI_MODEMADP_QUERY_PIN_LOCK,
    MMI_MODEMADP_TRY_PIN_REQ,
    MMI_MODEMADP_TRY_PIN2_REQ,
    MMI_MODEMADP_TRY_PUK_REQ,
    MMI_MODEMADP_TRY_PUK2_REQ,
    MMI_MODEMADP_CHG_PIN_REQ,
    MMI_MODEMADP_CHG_PIN2_REQ,
    MMI_MODEMADP_SIM_PRESENT_CHK_REQ,
    MMI_MODEMADP_GET_PB_STATUS_REQ,
    MMI_MODEMADP_GET_IMSI_REQ,
    MMI_MODEMADP_WRITE_PB_REQ,
    MMI_MODEMADP_READ_PB_REQ,
    MMI_MODEMADP_GET_ICCID_REQ,
    MMI_MODEMADP_GET_PLMN_REQ,
    MMI_MODEMADP_GET_MSISDN_REQ,
    MMI_MODEMADP_SEL_CHAR_SET_REQ,
    MMI_MODEMADP_SIM_SOFT_RESET_REQ,
    MMI_MODEMADP_SIM_MSG_ID_END = MMI_MODEMADP_SIM_SOFT_RESET_REQ,

    MMI_MODEMADP_MSG_ID_MAX,
} MMI_MODEMADP_MSG_ID_DEF;

typedef enum
{
    // network
    RIL_MODEMADP_NW_MSG_ID_START= MMI_MODEMADP_MSG_ID_MAX + 1,
    RIL_MODEMADP_RIL_READY_IND = RIL_MODEMADP_NW_MSG_ID_START,
    RIL_MODEMADP_MM_RSP_SET_NW_SEL_MANUAL,
    RIL_MODEMADP_MM_RSP_QUERY_AVAILABLE_NETWORKS,
    RIL_MODEMADP_MM_RSP_SIG_STRENGTH,
    RIL_MODEMADP_MM_RSP_RAT_CHANGED,
    RIL_MODEMADP_MM_RSP_NITZ_TIME_RECEIVED,
    RIL_MODEMADP_MM_RSP_NW_STATE_CHANGED,
    RIL_MODEMADP_MM_RSP_OPERATOR,
    RIL_MODEMADP_MM_RSP_IMS_REG_STATE,
    RIL_MODEMADP_MM_RSP_RADIO_POWER_STATUS,
    RIL_MODEMADP_MM_RSP_GET_BAND,
    RIL_MODEMADP_MM_RSP_CALI_INFO,
    RIL_MODEMADP_MM_RSP_GET_SN,
    RIL_MODEMADP_MM_RSP_BANDIND,
    RIL_MODEMADP_MM_IMS_VOPS,
    RIL_MODEMADP_NW_MSG_ID_END = RIL_MODEMADP_MM_IMS_VOPS,

    // call
    RIL_MODEMADP_CC_MSG_ID_START,
    RIL_MODEMADP_CC_RSP_RING   = RIL_MODEMADP_CC_MSG_ID_START,
    RIL_MODEMADP_CC_RSP_GET_IMEI,
    RIL_MODEMADP_CC_RSP_BASEBAND_VERSION,
    RIL_MODEMADP_CC_RSP_GET_CUR_CALLS,
    // RIL_MODEMADP_CC_RSP_CRING,                    //handled as RING
    RIL_MODEMADP_CC_RSP_CALL_DISCONNECT,
    RIL_MODEMADP_CC_RSP_NO_CARRIER,
    RIL_MODEMADP_CC_RSP_DIAL,
    RIL_MODEMADP_CC_RSP_CONN,
    RIL_MODEMADP_CC_RSP_CCWA,
    RIL_MODEMADP_CC_RSP_CLCC,
    RIL_MODEMADP_CC_RSP_CLIP,
    RIL_MODEMADP_CC_RSP_CMUT,
    RIL_MODEMADP_CC_RSP_CEER,
    RIL_MODEMADP_CC_MSG_ID_END    = RIL_MODEMADP_CC_RSP_CEER,

    // sms
    RIL_MODEMADP_SMS_MSG_ID_START,
    RIL_MODEMADP_MSG_RSP_SEND_SMS = RIL_MODEMADP_SMS_MSG_ID_START,
    RIL_MODEMADP_MSG_RSP_WRITE_SMS_TO_SIM,
    RIL_MODEMADP_MSG_RSP_READ_SMS_INFO_FROM_SIM,
    RIL_MODEMADP_MSG_RSP_READ_SINGLE_SMS_FROM_SIM,
    RIL_MODEMADP_MSG_RSP_GET_SMSC_ADDR,
    RIL_MODEMADP_MSG_RSP_NEW_SMS_ON_SIM,
    RIL_MODEMADP_MSG_RSP_SMS_STATUS_REP,
    RIL_MODEMADP_MSG_RSP_SMS_STORAGE_STATUS,
    // RIL_MODEMADP_MSG_RSP_GET_BROADCAST_SMS_CFG,   //not support
    RIL_MODEMADP_MSG_RSP_NEW_SMS,
    // RIL_MODEMADP_MSG_RSP_NEW_BROADCAST_SMS,       //not support
    RIL_MODEMADP_SMS_MSG_ID_END       = RIL_MODEMADP_MSG_RSP_NEW_SMS,

    // ss
    RIL_MODEMADP_SS_MSG_ID_START,
    RIL_MODEMADP_SS_RSP_CUSD          = RIL_MODEMADP_SS_MSG_ID_START,
    RIL_MODEMADP_SS_RSP_QUERY_CALL_FORWARD,
    RIL_MODEMADP_SS_RSP_SET_CALL_FORWARD,
    RIL_MODEMADP_SS_RSP_QUERY_CALL_WAITING,
    RIL_MODEMADP_SS_RSP_SET_CALL_WAITING,
    RIL_MODEMADP_SS_MSG_ID_END        = RIL_MODEMADP_SS_RSP_SET_CALL_WAITING,

    // sim
    RIL_MODEMADP_SIM_MSG_ID_START,
    RIL_MODEMADP_SIM_RSP_CP_PB_INITED = RIL_MODEMADP_SIM_MSG_ID_START,
    RIL_MODEMADP_SIM_RSP_GET_PB_STATUS,
    RIL_MODEMADP_SIM_RSP_WRITE_PB,
    RIL_MODEMADP_SIM_RSP_READ_PB,
    RIL_MODEMADP_SIM_RSP_GET_SIM_STATUS,
    RIL_MODEMADP_SIM_RSP_GET_IMSI,                // not support
    RIL_MODEMADP_SIM_RSP_QUERY_LOCK_INFO,
    RIL_MODEMADP_RSP_SET_FACILITY_LOCK,
    RIL_MODEMADP_RSP_QUERY_FACILITY_LOCK,
    RIL_MODEMADP_SIM_RSP_ENTER_SIM_PIN,
    RIL_MODEMADP_SIM_RSP_ENTER_SIM_PIN2,
    RIL_MODEMADP_SIM_RSP_ENTER_SIM_PUK,
    RIL_MODEMADP_SIM_RSP_ENTER_SIM_PUK2,
    RIL_MODEMADP_SIM_RSP_CHG_SIM_PIN,
    RIL_MODEMADP_SIM_RSP_CHG_SIM_PIN2,
    // RIL_MODEMADP_SIM_RSP_SIM_IO,                  //not support
    // RIL_MODEMADP_SIM_RSP_SIM_OPEN_CHANNEL,        //not support
    // RIL_MODEMADP_SIM_RSP_SIM_CLOSE_CHANNEL,       //not support
    RIL_MODEMADP_SIM_STATUS_CHANGED,
    RIL_MODEMADP_SIM_RSP_GET_ICCID,
    RIL_MODEMADP_SIM_RSP_GET_PLMN,
    RIL_MODEMADP_SIM_RSP_GET_MSISDN,
    RIL_MODEMADP_SIM_MSG_ID_END = RIL_MODEMADP_SIM_RSP_GET_MSISDN,

    RIL_MODEMADP_MSG_ID_MAX
} RIL_MODEMADP_MSG_ID_DEF;

extern VOID MMI_ModemAdp_NW_Init_Req(VOID);
extern VOID MMI_ModemAdp_Call_Init_Req(VOID);
extern VOID MMI_ModemAdp_Sms_Init_Req(VOID);
extern VOID MMI_ModemAdp_Ss_Init_Req(VOID);
extern VOID MMI_ModemAdp_Sim_Init_Req(VOID);
extern VOID MMI_ModemAdp_Video_Call_Init_Req(VOID);

extern VOID MMI_ModemAdp_NW_Msg_handle(UI_INTER_MSG_ID MsgId, UI_Inter_Msg_t *pMsg);
extern VOID MMI_ModemAdp_CC_Msg_handle(UI_INTER_MSG_ID MsgId, UI_Inter_Msg_t *pMsg);
extern VOID MMI_ModemAdp_Sms_Msg_handle(UI_INTER_MSG_ID MsgId, UI_Inter_Msg_t *pMsg);
extern VOID MMI_ModemAdp_Sim_Msg_handle(UI_INTER_MSG_ID MsgId, UI_Inter_Msg_t *pMsg);
extern VOID MMI_ModemAdp_SS_Msg_handle(UI_INTER_MSG_ID MsgId, UI_Inter_Msg_t *pMsg);
extern MMI_MODEM_SIM_ID  MMI_ModemAdp_Get_UI_SimId(RIL_SIM_ID RilSimId);
extern RIL_SIM_ID  MMI_ModemAdp_Get_Ril_SimId(MMI_MODEM_SIM_ID UiSimId);

extern MMI_MODEM_SIM_ID modem_sim_id;

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif /*SETTING_CALL_H*/
